package com.sokal.easycare.modules.picture.entity;

import org.hibernate.validator.constraints.Length;
import com.fasterxml.jackson.annotation.JsonBackReference;

import com.sokal.easycare.common.persistence.TreeEntity;

/**
 * 图文栏目Entity
 * @author liliangdong
 * @version 2017-03-22
 */
public class PicCategory extends TreeEntity<PicCategory> {
	
	private static final long serialVersionUID = 1L;
	private String name;		// 栏目名称
	private PicCategory parent;		// 栏目
	private String parentIds;		// 父级IDS
	private String keywords;		// 关键词
	private Integer sort;		// 排序
	
	public PicCategory() {
		super();
	}

	public PicCategory(String id){
		super(id);
	}

	@Length(min=1, max=100, message="栏目名称长度必须介于 1 和 100 之间")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@JsonBackReference
	public PicCategory getParent() {
		return parent;
	}

	public void setParent(PicCategory parent) {
		this.parent = parent;
	}
	
	@Length(min=0, max=1000, message="父级IDS长度必须介于 0 和 1000 之间")
	public String getParentIds() {
		return parentIds;
	}

	public void setParentIds(String parentIds) {
		this.parentIds = parentIds;
	}
	
	@Length(min=0, max=255, message="关键词长度必须介于 0 和 255 之间")
	public String getKeywords() {
		return keywords;
	}

	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}
	
	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}
	
	public String getParentId() {
		return parent != null && parent.getId() != null ? parent.getId() : "0";
	}
}